package com.bnzj.cloud.business.core.persistence.repository;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.bnzj.cloud.business.core.persistence.entity.ProcessNumber;
import com.bnzj.core.persistence.repository.BaseRepository;

@Repository
public interface ProcessNumberRepository extends BaseRepository<ProcessNumber, Long>{

	@Query(value="SELECT CONCAT(MAX(RIGHT(process_number,4))+1,'') FROM	 "
			+ " bnz_bas_process_number WHERE process_number LIKE ?1%",nativeQuery = true)
	public String queryByKeyDate(String keyDate);
	
	@Transactional
	@Modifying
	@Query(value="INSERT INTO bnz_bas_process_number (process_number) values (?1)",nativeQuery = true)
	public void insertProcessNumber(String processNumber);
}
